home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / usr / lib / ubiquity / plugins / ubi-intro.py < prev    next >
Text File  |  2009-10-13  |  2KB  |  73 lines

  1. # -*- coding: utf-8; Mode: Python; indent-tabs-mode: nil; tab-width: 4 -*-
  2. #
  3. # Copyright (C) 2009 Canonical Ltd.
  4. # Written by Michael Terry <michael.terry@canonical.com>.
  5. #
  6. # This file is part of Ubiquity.
  7. #
  8. # Ubiquity is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # Ubiquity is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with Ubiquity.  If not, see <http://www.gnu.org/licenses/>.
  20.  
  21. import os
  22. from ubiquity.plugin import *
  23.  
  24. NAME = 'intro'
  25. AFTER = None
  26. WEIGHT = 100
  27.  
  28. def get_intro():
  29.     """Get some introductory text, if available."""
  30.     if 'UBIQUITY_OEM_USER_CONFIG' in os.environ or \
  31.        'UBIQUITY_AUTOMATIC' in os.environ:
  32.         return None
  33.  
  34.     intro = None
  35.     introFiles = ['/usr/share/ubiquity/intro.txt', '/usr/share/ubiquity/kubuntu-netbook-intro.txt']
  36.     for file in introFiles:
  37.         if os.path.isfile(file):
  38.             intro = file
  39.             break
  40.     if intro is None:
  41.         return None
  42.  
  43.     intro_file = open(intro)
  44.     text = intro_file.read()
  45.     intro_file.close()
  46.     return text
  47.  
  48. class PageGtk(PluginUI):
  49.     def __init__(self, *args, **kwargs):
  50.         text = get_intro()
  51.         if text:
  52.             try:
  53.                 import gtk
  54.                 builder = gtk.Builder()
  55.                 builder.add_from_file('/usr/share/ubiquity/gtk/stepIntro.ui')
  56.                 builder.get_object('intro_label').set_markup(text.rstrip('\n'))
  57.                 self.plugin_widgets = builder.get_object('stepWelcome')
  58.             except Exception, e:
  59.                 self.debug('Could not create intro page: %s', e)
  60.  
  61. class PageKde(PluginUI):
  62.     plugin_breadcrumb = None
  63.  
  64.     def __init__(self, *args, **kwargs):
  65.         text = get_intro()
  66.         if text:
  67.             try:
  68.                 from PyQt4 import uic
  69.                 self.plugin_widgets = uic.loadUi('/usr/share/ubiquity/qt/stepIntro.ui')
  70.                 self.plugin_widgets.introLabel.setText(text.replace('\n', '<br>'))
  71.             except Exception, e:
  72.                 self.debug('Could not create intro page: %s', e)
  73.